package com.zxinlee.storage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zxinlee.storage.entity.Storage;
import org.apache.ibatis.annotations.Param;

public interface StorageMapper extends BaseMapper<Storage> {

    //扣减商品库存
    void decrease(@Param("productId") Long productId,
                  @Param("count") Integer count);

    //查询商品库存,用来判断是否有足够的库存用来冻结
    Storage findByProductId(Long productId);

    //冻结库存,把需要的可用库存修改为冻结状态
    void updateResidueToFrozen(Long productId, Integer count);

    //提交时,把冻结库存修改为已售出
    void updateFrozenToUsed(Long productId, Integer count);

    //回滚时,把冻结库存修改为可用库存
    void updateFrozenToResidue(Long productId, Integer count);
}
